<%@language=vbscript%>
<%
	Session("FormName")="F26"
%>
<HTML>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<link rel=stylesheet href="..\CSS\FormStyle.css" type="text/css">
<script language="javascript" src="..\JS\toolBarButton.js"></script>
<!--#include file="..\CheckSession.inc"-->
<!--#include file=..\getFormName.inc-->
</head>
<%
bComm=Request("bComm")
strdate=Request("strdate")
if strdate="" then
	strdate=date()
end if
if bComm="ok" then
	bngaydangky=strdate
	for i=1 to 8
		bid=Request("ID"&i)
		bthoigian=Request("Thoigian"&i)
		bthoigiankt=Request("Thoigiankt"&i)
		bnoidung=Request("Noidung"&i)
		bthanhphan=Request("Thanhphan"&i)
		bdiadiem=Request("Diadiem"&i)
		bghichu=Request("Ghichu"&i)
		Set RecDKL=server.CreateObject("ADODB.Recordset")
		RecDKL.CursorType=3
		RecDKL.CacheSize=5
		sSQL="select * from dklich where ID="& bid
		RecDKL.Open sSQL,Conn
		if bnoidung <> "" then 
			if RecDKL.Recordcount > 0 then
				sSQL="update dklich set thoigian='"& bthoigian &"',thoigiankt='"& bthoigiankt &"',noidung='"& bnoidung &"',thanhphan='"& bthanhphan &"',diadiem='"& bdiadiem &"',ghichu='"& bghichu &"' where ID="& bid
				Conn.Execute sSQL
			else
				sSQL="Insert into dklich(thoigian,thoigiankt,ngaydangky,noidung,thanhphan,diadiem,ghichu,ttdv,macanbo) values ('"& bthoigian &"','"& bthoigiankt &"','"& bngaydangky &"','"& bnoidung &"','"& bthanhphan &"','"& bdiadiem &"','"& bghichu &"',1,'"& Session("bMaCB") &"')"
				Conn.Execute sSQL
			end if
		else
			sSQL="delete dklich where ID="& bid
			Conn.Execute sSQL
		end if
		RecDKL.close
		Set RecDKL=nothing
	next
	btruc=Request("chk")
	if btruc="ON" then
		Set RecKTTruc=server.CreateObject("ADODB.Recordset")
		RecKTTruc.CursorType=3
		RecKTTruc.CacheSize=5
		sSQL="select * from dktruc where ngaydangky='"& bngaydangky &"' and macanbo='"& Session("bMaCB") &"' and ttdv=1 and tttruc=1"
		RecKTTruc.Open sSQL,Conn
		if RecKTTruc.recordcount <= 0 then
			sSQL="insert into dktruc(ngaydangky,tttruc,ttdv,macanbo) values ('"& bngaydangky &"',1,1,'"& Session("bMaCB") &"')"
			Conn.Execute sSQL
		end if
		RecKTTruc.close
		Set RecKTTruc=nothing
	else
		sSQL="delete dktruc where ngaydangky='"& bngaydangky &"' and macanbo='"& Session("bMaCB") &"' and ttdv=1"
		Conn.Execute sSQL
	end if
End if
%>
<script language=VBScript runat=server>
Function FormatDate(vDate)
	   If Not IsNull(vDate) Then
	        vM = Right("0" & Month(vDate), 2)
	        vD = Right("0" & Day(vDate), 2)
	        vY = Right("19" & Year(vDate), 4)
	        FormatDate = vD & "/" & vM & "/" & vY
	   End If
End Function
Function SaveDate(vDate)
		dim bvitri1
		dim bvitri2
	   vDate=trim(cstr(vDate))
	   bvitri1=instr(1,vDate,"/")
	   bMonth=left(vDate,bvitri1-1)
	   bvitri2=instr(bvitri1+1,vDate,"/")
	   Dim Temp
	   Temp=right(vDate,len(vDate)-bvitri1)
	   bDay=left(Temp,bvitri2-bvitri1-1)
	   bYear=right(vDate,len(vDate)-bvitri2)
       SaveDate=bDay+"/"+bMonth+"/"+bYear
End Function
Function Thu(strdate)
	bthu=weekday(strdate)
	select case bthu
		case 1
			Thu="Chủ Nhật"
		case 2
			Thu="Thứ Hai"
		case 3
			Thu="Thứ Ba"
		case 4
			Thu="Thứ Tư"
		case 5
			Thu="Thứ Năm"
		case 6
			Thu="Thứ Sáu"
		case 7
			Thu="Thứ Bảy"
	End select
End Function
</script>
<!--#include file="..\jvfunction.inc"-->
<SCRIPT LANGUAGE=javascript>
<!--
function CmdBack_onclick() {
	frm.target="main";
	frm.action="../leftmain.asp";
	frm.submit();
}
function CmdOK_onclick() {
	frm.action="test2tc.asp?bComm=ok&strdate="+"<%=strdate%>";
	frm.submit();
}
function Thoigian1_onkeyup(){
strtime=frm.Thoigian1.value;
keycode=window.event.keyCode;
intlen=strtime.length;
if (keycode==8 || (keycode>=37 && keycode<=40) || (keycode>=48 && keycode<=57) || (keycode>=96 && keycode<=105)){
if (keycode != 8){
	if (intlen==1){
		if (strtime > 2 && strtime < 10){
			frm.Thoigian1.value="0"+strtime+":";
		}
	}
	else
	{
		if (intlen==2){
			if (strtime > 9 && strtime < 24){
				frm.Thoigian1.value=strtime+":";
			}
			else
			{
				if (strtime >= 1 && strtime <= 9){
				frm.Thoigian1.value=strtime+":";
				}
				else
				{
				alert("Thời gian không hợp lệ !");
				frm.Thoigian1.value=strtime.substr(0,1);
				}
			}
		}
		else
		{
			if (intlen==4){
				strtime4=strtime.substr(3,1);
				if (strtime4 == "6" || strtime4 == "7" || strtime4 == "8" || strtime4 == "9"){
					alert("Thời gian không hợp lệ !");
					frm.Thoigian1.value=strtime.substr(0,3);
				}
			}
		}
	}
}
}
else{
	strtimef=strtime.substr(0,intlen-1)
	frm.Thoigian1.value=strtimef;
}
}
function Thoigian1_onBlur(){
	strtime=frm.Thoigian1.value;
	intlen=strtime.length;
	if (intlen==1){
		alert("Thời gian không hợp lệ !");
		frm.Thoigian1.focus();
	}
	else{
		if (intlen==3){
			frm.Thoigian1.value=strtime + "00";
		}
		else{
			if (intlen==4){
				frm.Thoigian1.value=strtime + "0";
			}
		}
	}
}
function Thoigian2_onkeyup(){
strtime=frm.Thoigian2.value;
keycode=window.event.keyCode;
intlen=strtime.length;
if (keycode==8 || (keycode>=37 && keycode<=40) || (keycode>=48 && keycode<=57) || (keycode>=96 && keycode<=105)){
if (keycode != 8){
	if (intlen==1){
		if (strtime > 2 && strtime < 10){
			frm.Thoigian2.value="0"+strtime+":";
		}
	}
	else
	{
		if (intlen==2){
			if (strtime > 9 && strtime < 24){
				frm.Thoigian2.value=strtime+":";
			}
			else
			{
				if (strtime >= 1 && strtime <= 9){
				frm.Thoigian2.value=strtime+":";
				}
				else
				{
				alert("Thời gian không hợp lệ !");
				frm.Thoigian2.value=strtime.substr(0,1);
				}
			}
		}
		else
		{
			if (intlen==4){
				strtime4=strtime.substr(3,1);
				if (strtime4 == "6" || strtime4 == "7" || strtime4 == "8" || strtime4 == "9"){
					alert("Thời gian không hợp lệ !");
					frm.Thoigian2.value=strtime.substr(0,3);
				}
			}
		}
	}
}
}
else{
	strtimef=strtime.substr(0,intlen-1)
	frm.Thoigian2.value=strtimef;
}
}
function Thoigian2_onBlur(){
	strtime=frm.Thoigian2.value;
	intlen=strtime.length;
	if (intlen==1){
		alert("Thời gian không hợp lệ !");
		frm.Thoigian2.focus();
	}
	else{
		if (intlen==3){
			frm.Thoigian2.value=strtime + "00";
		}
		else{
			if (intlen==4){
				frm.Thoigian2.value=strtime + "0";
			}
		}
	}
}
function Thoigian3_onkeyup(){
strtime=frm.Thoigian3.value;
keycode=window.event.keyCode;
intlen=strtime.length;
if (keycode==8 || (keycode>=37 && keycode<=40) || (keycode>=48 && keycode<=57) || (keycode>=96 && keycode<=105)){
if (keycode != 8){
	if (intlen==1){
		if (strtime > 2 && strtime < 10){
			frm.Thoigian3.value="0"+strtime+":";
		}
	}
	else
	{
		if (intlen==2){
			if (strtime > 9 && strtime < 24){
				frm.Thoigian3.value=strtime+":";
			}
			else
			{
				if (strtime >= 1 && strtime <= 9){
				frm.Thoigian3.value=strtime+":";
				}
				else
				{
				alert("Thời gian không hợp lệ !");
				frm.Thoigian3.value=strtime.substr(0,1);
				}
			}
		}
		else
		{
			if (intlen==4){
				strtime4=strtime.substr(3,1);
				if (strtime4 == "6" || strtime4 == "7" || strtime4 == "8" || strtime4 == "9"){
					alert("Thời gian không hợp lệ !");
					frm.Thoigian3.value=strtime.substr(0,3);
				}
			}
		}
	}
}
}
else{
	strtimef=strtime.substr(0,intlen-1)
	frm.Thoigian3.value=strtimef;
}
}
function Thoigian3_onBlur(){
	strtime=frm.Thoigian3.value;
	intlen=strtime.length;
	if (intlen==1){
		alert("Thời gian không hợp lệ !");
		frm.Thoigian3.focus();
	}
	else{
		if (intlen==3){
			frm.Thoigian3.value=strtime + "00";
		}
		else{
			if (intlen==4){
				frm.Thoigian3.value=strtime + "0";
			}
		}
	}
}
function Thoigian4_onkeyup(){
strtime=frm.Thoigian4.value;
keycode=window.event.keyCode;
intlen=strtime.length;
if (keycode==8 || (keycode>=37 && keycode<=40) || (keycode>=48 && keycode<=57) || (keycode>=96 && keycode<=105)){
if (keycode != 8){
	if (intlen==1){
		if (strtime > 2 && strtime < 10){
			frm.Thoigian4.value="0"+strtime+":";
		}
	}
	else
	{
		if (intlen==2){
			if (strtime > 9 && strtime < 24){
				frm.Thoigian4.value=strtime+":";
			}
			else
			{
				if (strtime >= 1 && strtime <= 9){
				frm.Thoigian4.value=strtime+":";
				}
				else
				{
				alert("Thời gian không hợp lệ !");
				frm.Thoigian4.value=strtime.substr(0,1);
				}
			}
		}
		else
		{
			if (intlen==4){
				strtime4=strtime.substr(3,1);
				if (strtime4 == "6" || strtime4 == "7" || strtime4 == "8" || strtime4 == "9"){
					alert("Thời gian không hợp lệ !");
					frm.Thoigian4.value=strtime.substr(0,3);
				}
			}
		}
	}
}
}
else{
	strtimef=strtime.substr(0,intlen-1)
	frm.Thoigian4.value=strtimef;
}
}
function Thoigian4_onBlur(){
	strtime=frm.Thoigian4.value;
	intlen=strtime.length;
	if (intlen==1){
		alert("Thời gian không hợp lệ !");
		frm.Thoigian4.focus();
	}
	else{
		if (intlen==3){
			frm.Thoigian4.value=strtime + "00";
		}
		else{
			if (intlen==4){
				frm.Thoigian4.value=strtime + "0";
			}
		}
	}
}
function Thoigian5_onkeyup(){
strtime=frm.Thoigian5.value;
keycode=window.event.keyCode;
intlen=strtime.length;
if (keycode==8 || (keycode>=37 && keycode<=40) || (keycode>=48 && keycode<=57) || (keycode>=96 && keycode<=105)){
if (keycode != 8){
	if (intlen==1){
		if (strtime > 2 && strtime < 10){
			frm.Thoigian5.value="0"+strtime+":";
		}
	}
	else
	{
		if (intlen==2){
			if (strtime > 9 && strtime < 24){
				frm.Thoigian5.value=strtime+":";
			}
			else
			{
				if (strtime >= 1 && strtime <= 9){
				frm.Thoigian5.value=strtime+":";
				}
				else
				{
				alert("Thời gian không hợp lệ !");
				frm.Thoigian5.value=strtime.substr(0,1);
				}
			}
		}
		else
		{
			if (intlen==4){
				strtime4=strtime.substr(3,1);
				if (strtime4 == "6" || strtime4 == "7" || strtime4 == "8" || strtime4 == "9"){
					alert("Thời gian không hợp lệ !");
					frm.Thoigian5.value=strtime.substr(0,3);
				}
			}
		}
	}
}
}
else{
	strtimef=strtime.substr(0,intlen-1)
	frm.Thoigian5.value=strtimef;
}
}
function Thoigian5_onBlur(){
	strtime=frm.Thoigian5.value;
	intlen=strtime.length;
	if (intlen==1){
		alert("Thời gian không hợp lệ !");
		frm.Thoigian5.focus();
	}
	else{
		if (intlen==3){
			frm.Thoigian5.value=strtime + "00";
		}
		else{
			if (intlen==4){
				frm.Thoigian5.value=strtime + "0";
			}
		}
	}
}
function Thoigian6_onkeyup(){
strtime=frm.Thoigian6.value;
keycode=window.event.keyCode;
intlen=strtime.length;
if (keycode==8 || (keycode>=37 && keycode<=40) || (keycode>=48 && keycode<=57) || (keycode>=96 && keycode<=105)){
if (keycode != 8){
	if (intlen==1){
		if (strtime > 2 && strtime < 10){
			frm.Thoigian6.value="0"+strtime+":";
		}
	}
	else
	{
		if (intlen==2){
			if (strtime > 9 && strtime < 24){
				frm.Thoigian6.value=strtime+":";
			}
			else
			{
				if (strtime >= 1 && strtime <= 9){
				frm.Thoigian6.value=strtime+":";
				}
				else
				{
				alert("Thời gian không hợp lệ !");
				frm.Thoigian6.value=strtime.substr(0,1);
				}
			}
		}
		else
		{
			if (intlen==4){
				strtime4=strtime.substr(3,1);
				if (strtime4 == "6" || strtime4 == "7" || strtime4 == "8" || strtime4 == "9"){
					alert("Thời gian không hợp lệ !");
					frm.Thoigian6.value=strtime.substr(0,3);
				}
			}
		}
	}
}
}
else{
	strtimef=strtime.substr(0,intlen-1)
	frm.Thoigian6.value=strtimef;
}
}
function Thoigian6_onBlur(){
	strtime=frm.Thoigian6.value;
	intlen=strtime.length;
	if (intlen==1){
		alert("Thời gian không hợp lệ !");
		frm.Thoigian6.focus();
	}
	else{
		if (intlen==3){
			frm.Thoigian6.value=strtime + "00";
		}
		else{
			if (intlen==4){
				frm.Thoigian6.value=strtime + "0";
			}
		}
	}
}
function Thoigian7_onkeyup(){
strtime=frm.Thoigian7.value;
keycode=window.event.keyCode;
intlen=strtime.length;
if (keycode==8 || (keycode>=37 && keycode<=40) || (keycode>=48 && keycode<=57) || (keycode>=96 && keycode<=105)){
if (keycode != 8){
	if (intlen==1){
		if (strtime > 2 && strtime < 10){
			frm.Thoigian7.value="0"+strtime+":";
		}
	}
	else
	{
		if (intlen==2){
			if (strtime > 9 && strtime < 24){
				frm.Thoigian7.value=strtime+":";
			}
			else
			{
				if (strtime >= 1 && strtime <= 9){
				frm.Thoigian7.value=strtime+":";
				}
				else
				{
				alert("Thời gian không hợp lệ !");
				frm.Thoigian7.value=strtime.substr(0,1);
				}
			}
		}
		else
		{
			if (intlen==4){
				strtime4=strtime.substr(3,1);
				if (strtime4 == "6" || strtime4 == "7" || strtime4 == "8" || strtime4 == "9"){
					alert("Thời gian không hợp lệ !");
					frm.Thoigian7.value=strtime.substr(0,3);
				}
			}
		}
	}
}
}
else{
	strtimef=strtime.substr(0,intlen-1)
	frm.Thoigian7.value=strtimef;
}
}
function Thoigian7_onBlur(){
	strtime=frm.Thoigian7.value;
	intlen=strtime.length;
	if (intlen==1){
		alert("Thời gian không hợp lệ !");
		frm.Thoigian7.focus();
	}
	else{
		if (intlen==3){
			frm.Thoigian7.value=strtime + "00";
		}
		else{
			if (intlen==4){
				frm.Thoigian7.value=strtime + "0";
			}
		}
	}
}
function Thoigian8_onkeyup(){
strtime=frm.Thoigian8.value;
keycode=window.event.keyCode;
intlen=strtime.length;
if (keycode==8 || (keycode>=37 && keycode<=40) || (keycode>=48 && keycode<=57) || (keycode>=96 && keycode<=105)){
if (keycode != 8){
	if (intlen==1){
		if (strtime > 2 && strtime < 10){
			frm.Thoigian8.value="0"+strtime+":";
		}
	}
	else
	{
		if (intlen==2){
			if (strtime > 9 && strtime < 24){
				frm.Thoigian8.value=strtime+":";
			}
			else
			{
				if (strtime >= 1 && strtime <= 9){
				frm.Thoigian8.value=strtime+":";
				}
				else
				{
				alert("Thời gian không hợp lệ !");
				frm.Thoigian8.value=strtime.substr(0,1);
				}
			}
		}
		else
		{
			if (intlen==4){
				strtime4=strtime.substr(3,1);
				if (strtime4 == "6" || strtime4 == "7" || strtime4 == "8" || strtime4 == "9"){
					alert("Thời gian không hợp lệ !");
					frm.Thoigian8.value=strtime.substr(0,3);
				}
			}
		}
	}
}
}
else{
	strtimef=strtime.substr(0,intlen-1)
	frm.Thoigian8.value=strtimef;
}
}
function Thoigian8_onBlur(){
	strtime=frm.Thoigian8.value;
	intlen=strtime.length;
	if (intlen==1){
		alert("Thời gian không hợp lệ !");
		frm.Thoigian8.focus();
	}
	else{
		if (intlen==3){
			frm.Thoigian8.value=strtime + "00";
		}
		else{
			if (intlen==4){
				frm.Thoigian8.value=strtime + "0";
			}
		}
	}
}
function Thoigiankt1_onkeyup(){
strtime=frm.Thoigiankt1.value;
keycode=window.event.keyCode;
intlen=strtime.length;
if (keycode==8 || (keycode>=37 && keycode<=40) || (keycode>=48 && keycode<=57) || (keycode>=96 && keycode<=105)){
if (keycode != 8){
	if (intlen==1){
		if (strtime > 2 && strtime < 10){
			frm.Thoigiankt1.value="0"+strtime+":";
		}
	}
	else
	{
		if (intlen==2){
			if (strtime > 9 && strtime < 24){
				frm.Thoigiankt1.value=strtime+":";
			}
			else
			{
				if (strtime >= 1 && strtime <= 9){
				frm.Thoigiankt1.value=strtime+":";
				}
				else
				{
				alert("Thời gian không hợp lệ !");
				frm.Thoigiankt1.value=strtime.substr(0,1);
				}
			}
		}
		else
		{
			if (intlen==4){
				strtime4=strtime.substr(3,1);
				if (strtime4 == "6" || strtime4 == "7" || strtime4 == "8" || strtime4 == "9"){
					alert("Thời gian không hợp lệ !");
					frm.Thoigiankt1.value=strtime.substr(0,3);
				}
			}
		}
	}
}
}
else{
	strtimef=strtime.substr(0,intlen-1)
	frm.Thoigiankt1.value=strtimef;
}
}
function Thoigiankt1_onBlur(){
	strtime=frm.Thoigiankt1.value;
	intlen=strtime.length;
	if (intlen==1){
		alert("Thời gian không hợp lệ !");
		frm.Thoigiankt1.focus();
	}
	else{
		if (intlen==3){
			frm.Thoigiankt1.value=strtime + "00";
		}
		else{
			if (intlen==4){
				frm.Thoigiankt1.value=strtime + "0";
			}
		}
	}
}
function Thoigiankt2_onkeyup(){
strtime=frm.Thoigiankt2.value;
keycode=window.event.keyCode;
intlen=strtime.length;
if (keycode==8 || (keycode>=37 && keycode<=40) || (keycode>=48 && keycode<=57) || (keycode>=96 && keycode<=105)){
if (keycode != 8){
	if (intlen==1){
		if (strtime > 2 && strtime < 10){
			frm.Thoigiankt2.value="0"+strtime+":";
		}
	}
	else
	{
		if (intlen==2){
			if (strtime > 9 && strtime < 24){
				frm.Thoigiankt2.value=strtime+":";
			}
			else
			{
				if (strtime >= 1 && strtime <= 9){
				frm.Thoigiankt2.value=strtime+":";
				}
				else
				{
				alert("Thời gian không hợp lệ !");
				frm.Thoigiankt2.value=strtime.substr(0,1);
				}
			}
		}
		else
		{
			if (intlen==4){
				strtime4=strtime.substr(3,1);
				if (strtime4 == "6" || strtime4 == "7" || strtime4 == "8" || strtime4 == "9"){
					alert("Thời gian không hợp lệ !");
					frm.Thoigiankt2.value=strtime.substr(0,3);
				}
			}
		}
	}
}
}
else{
	strtimef=strtime.substr(0,intlen-1)
	frm.Thoigiankt2.value=strtimef;
}
}
function Thoigiankt2_onBlur(){
	strtime=frm.Thoigiankt2.value;
	intlen=strtime.length;
	if (intlen==1){
		alert("Thời gian không hợp lệ !");
		frm.Thoigiankt2.focus();
	}
	else{
		if (intlen==3){
			frm.Thoigiankt2.value=strtime + "00";
		}
		else{
			if (intlen==4){
				frm.Thoigiankt2.value=strtime + "0";
			}
		}
	}
}
function Thoigiankt3_onkeyup(){
strtime=frm.Thoigiankt3.value;
keycode=window.event.keyCode;
intlen=strtime.length;
if (keycode==8 || (keycode>=37 && keycode<=40) || (keycode>=48 && keycode<=57) || (keycode>=96 && keycode<=105)){
if (keycode != 8){
	if (intlen==1){
		if (strtime > 2 && strtime < 10){
			frm.Thoigiankt3.value="0"+strtime+":";
		}
	}
	else
	{
		if (intlen==2){
			if (strtime > 9 && strtime < 24){
				frm.Thoigiankt3.value=strtime+":";
			}
			else
			{
				if (strtime >= 1 && strtime <= 9){
				frm.Thoigiankt3.value=strtime+":";
				}
				else
				{
				alert("Thời gian không hợp lệ !");
				frm.Thoigiankt3.value=strtime.substr(0,1);
				}
			}
		}
		else
		{
			if (intlen==4){
				strtime4=strtime.substr(3,1);
				if (strtime4 == "6" || strtime4 == "7" || strtime4 == "8" || strtime4 == "9"){
					alert("Thời gian không hợp lệ !");
					frm.Thoigiankt3.value=strtime.substr(0,3);
				}
			}
		}
	}
}
}
else{
	strtimef=strtime.substr(0,intlen-1)
	frm.Thoigiankt3.value=strtimef;
}
}
function Thoigiankt3_onBlur(){
	strtime=frm.Thoigiankt3.value;
	intlen=strtime.length;
	if (intlen==1){
		alert("Thời gian không hợp lệ !");
		frm.Thoigiankt3.focus();
	}
	else{
		if (intlen==3){
			frm.Thoigiankt3.value=strtime + "00";
		}
		else{
			if (intlen==4){
				frm.Thoigiankt3.value=strtime + "0";
			}
		}
	}
}
function Thoigiankt4_onkeyup(){
strtime=frm.Thoigiankt4.value;
keycode=window.event.keyCode;
intlen=strtime.length;
if (keycode==8 || (keycode>=37 && keycode<=40) || (keycode>=48 && keycode<=57) || (keycode>=96 && keycode<=105)){
if (keycode != 8){
	if (intlen==1){
		if (strtime > 2 && strtime < 10){
			frm.Thoigiankt4.value="0"+strtime+":";
		}
	}
	else
	{
		if (intlen==2){
			if (strtime > 9 && strtime < 24){
				frm.Thoigiankt4.value=strtime+":";
			}
			else
			{
				if (strtime >= 1 && strtime <= 9){
				frm.Thoigiankt4.value=strtime+":";
				}
				else
				{
				alert("Thời gian không hợp lệ !");
				frm.Thoigiankt4.value=strtime.substr(0,1);
				}
			}
		}
		else
		{
			if (intlen==4){
				strtime4=strtime.substr(3,1);
				if (strtime4 == "6" || strtime4 == "7" || strtime4 == "8" || strtime4 == "9"){
					alert("Thời gian không hợp lệ !");
					frm.Thoigiankt4.value=strtime.substr(0,3);
				}
			}
		}
	}
}
}
else{
	strtimef=strtime.substr(0,intlen-1)
	frm.Thoigiankt4.value=strtimef;
}
}
function Thoigiankt4_onBlur(){
	strtime=frm.Thoigiankt4.value;
	intlen=strtime.length;
	if (intlen==1){
		alert("Thời gian không hợp lệ !");
		frm.Thoigiankt4.focus();
	}
	else{
		if (intlen==3){
			frm.Thoigiankt4.value=strtime + "00";
		}
		else{
			if (intlen==4){
				frm.Thoigiankt4.value=strtime + "0";
			}
		}
	}
}
function Thoigiankt5_onkeyup(){
strtime=frm.Thoigiankt5.value;
keycode=window.event.keyCode;
intlen=strtime.length;
if (keycode==8 || (keycode>=37 && keycode<=40) || (keycode>=48 && keycode<=57) || (keycode>=96 && keycode<=105)){
if (keycode != 8){
	if (intlen==1){
		if (strtime > 2 && strtime < 10){
			frm.Thoigiankt5.value="0"+strtime+":";
		}
	}
	else
	{
		if (intlen==2){
			if (strtime > 9 && strtime < 24){
				frm.Thoigiankt5.value=strtime+":";
			}
			else
			{
				if (strtime >= 1 && strtime <= 9){
				frm.Thoigiankt5.value=strtime+":";
				}
				else
				{
				alert("Thời gian không hợp lệ !");
				frm.Thoigiankt5.value=strtime.substr(0,1);
				}
			}
		}
		else
		{
			if (intlen==4){
				strtime4=strtime.substr(3,1);
				if (strtime4 == "6" || strtime4 == "7" || strtime4 == "8" || strtime4 == "9"){
					alert("Thời gian không hợp lệ !");
					frm.Thoigiankt5.value=strtime.substr(0,3);
				}
			}
		}
	}
}
}
else{
	strtimef=strtime.substr(0,intlen-1)
	frm.Thoigiankt5.value=strtimef;
}
}
function Thoigiankt5_onBlur(){
	strtime=frm.Thoigiankt5.value;
	intlen=strtime.length;
	if (intlen==1){
		alert("Thời gian không hợp lệ !");
		frm.Thoigiankt5.focus();
	}
	else{
		if (intlen==3){
			frm.Thoigiankt5.value=strtime + "00";
		}
		else{
			if (intlen==4){
				frm.Thoigiankt5.value=strtime + "0";
			}
		}
	}
}
function Thoigiankt6_onkeyup(){
strtime=frm.Thoigiankt6.value;
keycode=window.event.keyCode;
intlen=strtime.length;
if (keycode==8 || (keycode>=37 && keycode<=40) || (keycode>=48 && keycode<=57) || (keycode>=96 && keycode<=105)){
if (keycode != 8){
	if (intlen==1){
		if (strtime > 2 && strtime < 10){
			frm.Thoigiankt6.value="0"+strtime+":";
		}
	}
	else
	{
		if (intlen==2){
			if (strtime > 9 && strtime < 24){
				frm.Thoigiankt6.value=strtime+":";
			}
			else
			{
				if (strtime >= 1 && strtime <= 9){
				frm.Thoigiankt6.value=strtime+":";
				}
				else
				{
				alert("Thời gian không hợp lệ !");
				frm.Thoigiankt6.value=strtime.substr(0,1);
				}
			}
		}
		else
		{
			if (intlen==4){
				strtime4=strtime.substr(3,1);
				if (strtime4 == "6" || strtime4 == "7" || strtime4 == "8" || strtime4 == "9"){
					alert("Thời gian không hợp lệ !");
					frm.Thoigiankt6.value=strtime.substr(0,3);
				}
			}
		}
	}
}
}
else{
	strtimef=strtime.substr(0,intlen-1)
	frm.Thoigiankt6.value=strtimef;
}
}
function Thoigiankt6_onBlur(){
	strtime=frm.Thoigiankt6.value;
	intlen=strtime.length;
	if (intlen==1){
		alert("Thời gian không hợp lệ !");
		frm.Thoigiankt6.focus();
	}
	else{
		if (intlen==3){
			frm.Thoigiankt6.value=strtime + "00";
		}
		else{
			if (intlen==4){
				frm.Thoigiankt6.value=strtime + "0";
			}
		}
	}
}
function Thoigiankt7_onkeyup(){
strtime=frm.Thoigiankt7.value;
keycode=window.event.keyCode;
intlen=strtime.length;
if (keycode==8 || (keycode>=37 && keycode<=40) || (keycode>=48 && keycode<=57) || (keycode>=96 && keycode<=105)){
if (keycode != 8){
	if (intlen==1){
		if (strtime > 2 && strtime < 10){
			frm.Thoigiankt7.value="0"+strtime+":";
		}
	}
	else
	{
		if (intlen==2){
			if (strtime > 9 && strtime < 24){
				frm.Thoigiankt7.value=strtime+":";
			}
			else
			{
				if (strtime >= 1 && strtime <= 9){
				frm.Thoigiankt7.value=strtime+":";
				}
				else
				{
				alert("Thời gian không hợp lệ !");
				frm.Thoigiankt7.value=strtime.substr(0,1);
				}
			}
		}
		else
		{
			if (intlen==4){
				strtime4=strtime.substr(3,1);
				if (strtime4 == "6" || strtime4 == "7" || strtime4 == "8" || strtime4 == "9"){
					alert("Thời gian không hợp lệ !");
					frm.Thoigiankt7.value=strtime.substr(0,3);
				}
			}
		}
	}
}
}
else{
	strtimef=strtime.substr(0,intlen-1)
	frm.Thoigiankt7.value=strtimef;
}
}
function Thoigiankt7_onBlur(){
	strtime=frm.Thoigiankt7.value;
	intlen=strtime.length;
	if (intlen==1){
		alert("Thời gian không hợp lệ !");
		frm.Thoigiankt7.focus();
	}
	else{
		if (intlen==3){
			frm.Thoigiankt7.value=strtime + "00";
		}
		else{
			if (intlen==4){
				frm.Thoigiankt7.value=strtime + "0";
			}
		}
	}
}
function Thoigiankt8_onkeyup(){
strtime=frm.Thoigiankt8.value;
keycode=window.event.keyCode;
intlen=strtime.length;
if (keycode==8 || (keycode>=37 && keycode<=40) || (keycode>=48 && keycode<=57) || (keycode>=96 && keycode<=105)){
if (keycode != 8){
	if (intlen==1){
		if (strtime > 2 && strtime < 10){
			frm.Thoigiankt8.value="0"+strtime+":";
		}
	}
	else
	{
		if (intlen==2){
			if (strtime > 9 && strtime < 24){
				frm.Thoigiankt8.value=strtime+":";
			}
			else
			{
				if (strtime >= 1 && strtime <= 9){
				frm.Thoigiankt8.value=strtime+":";
				}
				else
				{
				alert("Thời gian không hợp lệ !");
				frm.Thoigiankt8.value=strtime.substr(0,1);
				}
			}
		}
		else
		{
			if (intlen==4){
				strtime4=strtime.substr(3,1);
				if (strtime4 == "6" || strtime4 == "7" || strtime4 == "8" || strtime4 == "9"){
					alert("Thời gian không hợp lệ !");
					frm.Thoigiankt8.value=strtime.substr(0,3);
				}
			}
		}
	}
}
}
else{
	strtimef=strtime.substr(0,intlen-1)
	frm.Thoigiankt8.value=strtimef;
}
}
function Thoigiankt8_onBlur(){
	strtime=frm.Thoigiankt8.value;
	intlen=strtime.length;
	if (intlen==1){
		alert("Thời gian không hợp lệ !");
		frm.Thoigiankt8.focus();
	}
	else{
		if (intlen==3){
			frm.Thoigiankt8.value=strtime + "00";
		}
		else{
			if (intlen==4){
				frm.Thoigiankt8.value=strtime + "0";
			}
		}
	}
}
//-->
</SCRIPT>
<script language="javascript">
function ShowCalender(){
frm.changedate.value="True";
showModalDialog("calendar.asp",window,"dialogWidth:4.9cm;dialogHeight:4.8cm;dialogTop:4.6cm;dialogLeft:5.4cm;Help:No;Resizable:No;Status:No;");
//remote = window.open('calendar.asp','new_page','width=175,height=153,top=215,left=2,Resizable=no').focus();
}
function onclick_changedate(){
	strcookie=document.cookie;
	intvt1=strcookie.indexOf("changedate=");
	intvt2=strcookie.indexOf(";",intvt1)
	strchangedate=strcookie.substr(intvt1+11,intvt2-intvt1-11)
	strdateold=frm.changedate.value;
	if (strdateold=="True"){
		frm.changedate.value="";
		frm.action="test2tc.asp?bComm=''&strdate="+strchangedate;
		frm.submit();
	}
}
</script>
<body bgcolor=#f8f9d9 topmargin=0 leftmargin=0 rightmargin=0 style="FONT-FAMILY: Time New Roman" SCROLL=NO>
<form name=frm method=post onclick="javascript:onclick_changedate()">
<input type="hidden" name="changedate">
<table border="0" width="100%" bgcolor="#7491DC" style="border-top: 1px #EEEEEE solid;border-left: 1px #EEEEEE solid;border-bottom: 1px #848284 solid;border-right: 1px #848284 solid">
    <tr>
      <TD WIDTH="100%" COLSPAN="7" BGCOLOR="#7491DC"><P ALIGN="CENTER"><FONT FACE="Times New Roman" COLOR="#FFFFFF" SIZE=2><b>ĐĂNG KÝ LỊCH LÀM VIỆC CỦA CỤC</b></FONT></P></TD>
    </tr>
</table>
<table id=toolbar cellspacing="0">
	<tr><td> 
		<table cellspacing="0">
			<tr> 
				<td><img src="..\images\icons\button_seperator.gif" align="absmiddle" width="12" height="20"></td>
				<td class="toolBarButton" title="Ghi nhận đăng ký lịch" id=btnghinhan onaction="CmdOK_onclick()"><img src="..\images\icons\button_save.gif" align="absmiddle" width="16" height="20">&nbsp;&nbsp;Ghi nhận</td>
				<td class="toolBarButton" title="Trở về của sổ chính" id=btnquaylai onaction="CmdBack_onclick()"><img src="..\images\icons\button_back.gif" align="absmiddle" width="16" height="20">&nbsp;Quay lại</td>
				<td><img src="..\images\icons\button_seperator.gif" align="absmiddle" width="12" height="20"></td>
				<td class="toolBarButton" title="Chọn ngày tháng" id=btncalendar onaction="ShowCalender()">&nbsp;<img src="..\images\button_calendarpop.gif" align="absmiddle" width="16" height="20">&nbsp;</td>
				<td class="toolBarButton"><b>&nbsp;<%=Thu(strdate)%>&nbsp;&nbsp;<%=FormatDate(strdate)%></b></td>
			</tr>
		</table>
	</tr></td>
</table>
<script>
var btn;
	btn = document.getElementById("btnghinhan");createButton(btn);btn.setEnabled(true);
	btn = document.getElementById("btnquaylai");createButton(btn);btn.setEnabled(true);
	btn = document.getElementById("btncalendar");createButton(btn);btn.setEnabled(true);
</script>
<table class=tblHeader id=ListHeader border=0 cellspacing=0 cellpadding=0>
	<tr>
		<TD width=6% align=center>TGBĐ</TD>
		<TD width=6% align=center>TGKT</TD>
		<TD width=22% align=center>Nội dung</TD>
		<TD width=22% align=center>Thành phần</TD>
		<TD width=22% align=center>Địa điểm</TD>
		<TD width=22% align=center>Ghi chú</TD>
	</tr>
</table>
	<table width=100% border=0 cellspacing=0 cellpadding=0>
		<%
		stt=1
		Set RecLich=server.CreateObject("ADODB.Recordset")
		RecLich.CursorType=3
		RecLich.CacheSize=5
		sSQL="select * from dklich where ngaydangky='"& strdate &"' and macanbo='"& Session("bMaCB") &"' and ttdv=1 order by ID"
		RecLich.Open sSQL,Conn
		Do while Not RecLich.EOF
		%>
		<TR>
			<TD width=6%><INPUT type="hidden" name=ID<%=stt%> value="<%=RecLich("ID")%>"><INPUT name=Thoigian<%=stt%> value="<%=trim(RecLich("Thoigian"))%>" size=5 maxlength=5 style="FONT-FAMILY: Time New Roman;font-size:11px;border: 1px solid #C0C0C0;width:100%" LANGUAGE=javascript onkeyup="return Thoigian<%=stt%>_onkeyup()" onBlur="return Thoigian<%=stt%>_onBlur()"></TD>
			<TD width=6%><INPUT name=Thoigiankt<%=stt%> value="<%=trim(RecLich("Thoigiankt"))%>" size=5 maxlength=5 style="FONT-FAMILY: Time New Roman;font-size:11px;border: 1px solid #C0C0C0;width:100%" LANGUAGE=javascript onkeyup="return Thoigiankt<%=stt%>_onkeyup()" onBlur="return Thoigiankt<%=stt%>_onBlur()"></TD>
			<TD width=22%><INPUT name=Noidung<%=stt%> value="<%=trim(RecLich("Noidung"))%>" size=33 style="FONT-FAMILY: Time New Roman;font-size:11px;border: 1px solid #C0C0C0;width:100%"></TD>
			<TD width=22%><INPUT name=Thanhphan<%=stt%> value="<%=trim(RecLich("Thanhphan"))%>" size=30 style="FONT-FAMILY: Time New Roman;font-size:11px;border: 1px solid #C0C0C0;width:100%"></TD>
			<TD width=22%><INPUT name=Diadiem<%=stt%>  value="<%=trim(RecLich("Diadiem"))%>" size=30 style="FONT-FAMILY: Time New Roman;font-size:11px;border: 1px solid #C0C0C0;width:100%"></TD>
			<TD width=22%><INPUT name=Ghichu<%=stt%>  value="<%=trim(RecLich("Ghichu"))%>" size=20 style="FONT-FAMILY: Time New Roman;font-size:11px;border: 1px solid #C0C0C0;width:100%"></TD>
		</TR>
		<%
		stt=stt+1
		RecLich.MoveNext
		loop
		RecLich.close
		set RecLich=nothing
		%>
		<%for i=stt to 8%>
		<TR>
			<TD width=6%><INPUT type="hidden" name=ID<%=i%> value="0"><INPUT name=Thoigian<%=i%> value="" size=5 maxlength=5 style="FONT-FAMILY: Time New Roman;font-size:11px;border: 1px solid #C0C0C0;width:100%" LANGUAGE=javascript onkeyup="return Thoigian<%=i%>_onkeyup()" onBlur="return Thoigian<%=i%>_onBlur()"></TD>
			<TD width=6%><INPUT name=Thoigiankt<%=i%> value="" size=5 maxlength=5 style="FONT-FAMILY: Time New Roman;font-size:11px;border: 1px solid #C0C0C0;width:100%" LANGUAGE=javascript onkeyup="return Thoigiankt<%=i%>_onkeyup()" onBlur="return Thoigiankt<%=i%>_onBlur()"></TD>
			<TD width=22%><INPUT name=Noidung<%=i%> value="" size=33 style="FONT-FAMILY: Time New Roman;font-size:11px;border: 1px solid #C0C0C0;width:100%"></TD>
			<TD width=22%><INPUT name=Thanhphan<%=i%> value="" size=30 style="FONT-FAMILY: Time New Roman;font-size:11px;border: 1px solid #C0C0C0;width:100%"></TD>
			<TD width=22%><INPUT name=Diadiem<%=i%>  value="" size=30 style="FONT-FAMILY: Time New Roman;font-size:11px;border: 1px solid #C0C0C0;width:100%"></TD>
			<TD width=22%><INPUT name=Ghichu<%=i%>  value="" size=20 style="FONT-FAMILY: Time New Roman;font-size:11px;border: 1px solid #C0C0C0;width:100%"></TD>
		</TR>
		<%next%>
			<tr>
				 <td colspan=5> 
			      <table bgColor="#eeeecc" border="0" cellPadding="0" cellSpacing="0">
				   	<tr>
		        	<td width=20%>Đăng ký trực</td>
						<td width=10% align="center">
							<%
							Set RecTruc=server.CreateObject("ADODB.Recordset")
							RecTruc.CursorType=3
							RecTruc.CacheSize=5
							sSQL="select * from dktruc where ngaydangky='"& strdate &"' and macanbo='"& Session("bMaCB") &"' and ttdv=1 and tttruc=1"
							RecTruc.Open sSQL,Conn
							if RecTruc.recordcount > 0 then
							%>
								<INPUT TYPE="checkbox" NAME="chk" checked value="ON">
							<%else%>
								<INPUT TYPE="checkbox" NAME="chk" value="ON">					
							<%end if
							RecTruc.close
							set RecTruc=nothing
							%>
						</td>
						<td width=70%></td>
				     </tr>
				</table>
				</td>
			</tr>
</table>
</form>
</BODY>
</HTML>